import java.io.IOException;


public class RosterParser extends Parser
{
    int year;
    public RosterParser(String file) throws IOException
    {
        super(file);
        year = Integer.parseInt(file.substring(3, 7));
    }

    @Override
    public void parse() throws IOException
    {
        String line;
        while ((line = reader.readLine()) != null)
        {
            String[] fields = line.split(",");
            
            String id = fields[0];
            String tid = fields[5];
            String since = year + "0101";
            String until = year + "1231";
            
            writer.write("INSERT INTO Plays_for (playerid, tid, since, until) VALUES ('" + id + "', '" + tid + "', TO_DATE('" + since
                    + "', 'yyyymmdd'), TO_DATE('" + until + "', 'yyyymmdd'));\n");
        }
        reader.close();
        writer.close();
    }
}
